*********************
*This file contains the code to generate results in
*ONLINE APPENDIX S3
***********************
set more off

***********
*Table S3.1
************
use dataKR2, clear
keep if kantonsrat==16
*Define variables
gen Attend_z = attend
qui sum Attend_z, d
qui replace Attend_z = (Attend_z-r(mean))/r(sd)
global MP = "mLocPol mDr mNR age mWorker mFarmer"
*Models reported in table
reg Reelect1914 Attend_z if mExit != 1 , vce(clu wk)
xtreg Reelect1914 Attend_z if mExit != 1, i(wk) fe vce(clu wk)
xtreg Reelect1914 Attend_z $MP if mExit != 1, i(wk) fe vce(clu wk)
xtreg Reelect1914 Attend_z $MP if mExit != 1 & age < 68, i(wk) fe vce(clu wk)
xtreg Reelect1914 Attend_z $MP if mExit != 2 & wkSeats> 2, i(wk) fe vce(clu wk)
xtreg Reelect1914 Attend_z c.Attend_z#c.wkSeatslog $MP if mExit != 1, i(wk) fe vce(clu wk)

***********
*Figure S3.1
************

*Plot mfx
qui xtreg Reelect1914 Attend_z c.Attend_z#c.wkSeatslog $MP if mExit != 1, i(wk) fe vce(clu wk)
qui margins, dydx(Attend_z) at(wkSeatslog = (0 (0.1) 3.3))
marginsplot, xtitle("District magnitude (log)") ytitle("Marginal effect of attendance on reelection") ///
title("") yline(0)  recast(line) recastci(rarea) xlabel(0 (1) 3) /// 
text(-0.16 0 "p1") text(-0.16 1.1 "p25") text(-0.16 1.615 "p50") text(-0.16 2.3 "p75") text(-0.16 3.3 "p99")
graph export fig-reelection.pdf, replace



************
*Table S3.2
*************
use dataKR2, clear
keep if kantonsrat==17
global MP = "age mWorker mFarmer mNR LeftParty"
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
nbreg  spn_tot attend  $X if pres != 1 & mDeath != 1 & mReplacement!=1
nbreg  spn_tot attend  $MP $X if pres != 1 & mDeath != 1 & mReplacement!=1
nbreg  spn_tot attend  mDr $MP $X if pres != 1 & mDeath != 1 & mReplacement!=1


************
*Table S3.3
*************
use dataKR3, clear
*Reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Outcome and controls
global y  = "spn"
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share ref" 
global MP = "age mWorker mFarmer mNR LeftParty FarmersParty"
*Models
xtnbreg  $y RatioDM_kr18 RatioDM i.kantonsrat $X if  pres != 1 & mDeath != 1 & mReplacement!=1, i(sID) re
xtnbreg  $y RatioDM_kr18 RatioDM i.kantonsrat $X i.wk18 if  pres != 1 & mDeath != 1 & mReplacement!=1, i(sID) re
xtnbreg  $y RatioDM_kr18 RatioDM i.kantonsrat $X $MP i.wk18 if  pres != 1 & mDeath != 1 & mReplacement!=1, i(sID) re

************
*Table S3.4
*************
set more off
use dataKR2, clear
*Reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Trends varying by RatioDM
recode RatioDM (0/0.69 = 1) (0.6901/1.1 = 2) (1.101/1.39 = 3) (1.3901/max = 4), gen(RefIntCat)
qui tab RefIntCat, gen(RefIntc)
gen RefIntc1_trend = RefIntc1*kantonsrat
gen RefIntc2_trend = RefIntc2*kantonsrat
gen RefIntc3_trend = RefIntc3*kantonsrat
gen RefIntc4_trend = RefIntc4*kantonsrat
*Outcome, district controls and MP characteristics
global y  = "attend" 
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR LeftParty FarmersParty"
*Models
reg mDr RatioDM_kr18 RatioDM i.kantonsrat $X if kantonsrat != 16, vce(clu wk18)
xtreg mDr RatioDM_kr18   i.kantonsrat $X if kantonsrat != 16, i(wk18) fe vce(clu wk18)
reg mDr RatioDM_kr18  RatioDM i.kantonsrat $X, vce(clu wk18)
xtreg mDr RatioDM_kr18   i.kantonsrat $X, i(wk18) fe vce(clu wk18)
xtreg mDr RatioDM_kr18 i.kantonsrat RefIntc2_trend RefIntc3_trend RefIntc4_trend $X, i(wk18) fe vce(clu wk18)




************
*Table S3.5
*************
use dataKR2, clear
drop if kantonsrat==16
*Reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Controls
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR LeftParty FarmersParty"
*Models
reg mLocPol RatioDM_kr18 RatioDM i.kantonsrat $X, vce(clu wk18)
xtreg mLocPol RatioDM_kr18  i.kantonsrat $X, i(wk18) fe vce(clu wk18)
xtreg mLocPol RatioDM_kr18 i.kantonsrat $MP $X, i(wk18) fe vce(clu wk18)



********************
*TABLE S3.6
***********************

*First, congruence models (columns 1-3)
use dataKR1, clear
*Reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*District magnitude
global ldm  = "wkSeatslog" 
*Outcome, district controls and MP characteristics
*Alternative congruence measures
gen cong_ent2 = congruence
replace cong_ent2 = 0 if vVote==8 | vVote==9 | vVote==10
gen cong_ent3 = congruence
replace cong_ent3 = 1 if vVote==8 | vVote==9 | vVote==10
*Controls  
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR LeftParty FarmersParty"
*Models 1-3
xtreg cong_ent3 RatioDM_kr18 kr18 $X i.vID, i(wk18) fe vce(clu wk18)
xtreg cong_ent2 RatioDM_kr18 kr18 $X i.vID, i(wk18) fe vce(clu wk18)
xtreg congruence $ldm kr18 $X  i.vID, i(wk18) fe vce(clu wk18)


*Second, attendance models (columns 4-6)
use dataKR2, clear
*Reform intensity, pre-treatmend trend and district magnitude
gen RatioDM_kr18 = RatioDM*kr18
gen RatioDM_kr16 = RatioDM
replace RatioDM_kr16 = 0 if kantonsrat > 16
global ldm  = "wkSeatslog" 
*Trends varying by RatioDM
recode RatioDM (0/0.69 = 1) (0.6901/1.1 = 2) (1.101/1.39 = 3) (1.3901/max = 4), gen(RefIntCat)
qui tab RefIntCat, gen(RefIntc)
gen RefIntc1_trend = RefIntc1*kantonsrat
gen RefIntc2_trend = RefIntc2*kantonsrat
gen RefIntc3_trend = RefIntc3*kantonsrat
gen RefIntc4_trend = RefIntc4*kantonsrat
*Outcome, district controls and MP characteristics
global y  = "attend" 
global y2  = "attend2" 
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR LeftParty FarmersParty"
*Models 
reg $y2   RatioDM_kr18 RatioDM kr18 $X if kantonsrat != 16, vce(clu wk18)
xtreg $y $ldm kr18 $X if kantonsrat != 16, i(wk18) fe vce(clu wk18)
xtreg $y RatioDM_kr18 RatioDM_kr16 i.kantonsrat $X RefIntc2_trend RefIntc3_trend RefIntc4_trend, i(wk18) fe vce(clu wk18)


********************
*TABLE S3.7
***********************
use dataKR1, clear 
drop if mReplacement == 1
*Aggregate by post-reform district and vote
collapse (mean) kantonsrat kr18 RatioDM congruence MPvote JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share, by(vID wk18)
*Define reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Alternative congruence (reviewer): average popular support minus average legislative support on a given issue in a district.
*Canton-level support in referendum
gen CantonVote = .
replace CantonVote = 0.5343 if vID ==  17427 
replace CantonVote = 0.5911 if vID ==  17460 
replace CantonVote = 0.8580 if vID ==  18431
replace CantonVote = 0.2791 if vID ==  18615
replace CantonVote = 0.4586 if vID ==  18511
gen distance  = abs(CantonVote - MPvote)
*Controls
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
*Models
regress congruence RatioDM_kr18 RatioDM  kr18 $X i.vID, vce(clu wk18)
xtreg congruence RatioDM_kr18  i.kantonsrat i.vID, i(wk18) fe vce(clu wk18)
xtreg congruence RatioDM_kr18  i.kantonsrat $X i.vID, i(wk18) fe vce(clu wk18)
regress distance RatioDM_kr18 RatioDM  kr18 $X i.vID, vce(clu wk18)
xtreg distance RatioDM_kr18  i.kantonsrat  i.vID, i(wk18) fe vce(clu wk18)
xtreg distance RatioDM_kr18  i.kantonsrat $X i.vID, i(wk18) fe vce(clu wk18)


********************
*TABLE S3.8
***********************

**Congruence models
use dataKR1, clear
drop if wkBezirk==11
*Reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Outcome, district controls and MP characteristics
global y  = "congruence"  
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR LeftParty FarmersParty"
*Models for columns 1-3 are on individual-level
reg $y   RatioDM_kr18 RatioDM kr18 $X i.vID, vce(clu wk18)
xtreg $y RatioDM_kr18 kr18 $X  i.vID, i(wk18) fe vce(clu wk18)
xtreg $y RatioDM_kr18 kr18 $MP $X  i.vID, i(wk18) fe vce(clu wk18)
*Model in column 4 is on post-reform district level 
drop if mReplacement == 1
collapse (mean) kantonsrat kr18 RatioDM congruence JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share, by(vID wk18)
*Define reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Alternative congruence: does a majority of MPs vote in line with popular majority?
* generate indicator for whether a majority of MPs in post-reform districts votes with public opinion on each issue
gen conmajmps = 0
replace conmajmps = 1 if congruence >= 0.5
xtreg conmajmps RatioDM_kr18 i.kantonsrat $X i.vID, i(wk18) fe vce(clu wk18)

**Attendance models
use dataKR2, clear
drop if kantonsrat==16 | wkBezirk==11
*Reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Outcome, district controls and MP characteristics
global y  = "attend" 
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR LeftParty FarmersParty"
*Models columns 5-7
reg $y   RatioDM_kr18 RatioDM kr18 $X, vce(clu wk18)
xtreg $y RatioDM_kr18 kr18 $X, i(wk18) fe vce(clu wk18)
xtreg $y RatioDM_kr18 kr18 $MP $X, i(wk18) fe vce(clu wk18)



********************
*TABLE S3.9
***********************
*Pre-reform DM
clear
import excel data_wahlkreise, firstrow
collapse (mean) wkSeats, by(wk18)
gen preDM = wkSeats
keep wk18 preDM
save preDM, replace

**Congruence models
use dataKR1, clear
merge m:1 wk18 using  preDM
*Reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Outcome, district controls and MP characteristics
global y  = "congruence"  
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR LeftParty FarmersParty"
*Models for columns 1-3 are on individual-level
reg $y c.RatioDM_kr18##c.preDM RatioDM i.kantonsrat $X, vce(clu wk18)
xtreg $y c.RatioDM_kr18 c.RatioDM_kr18#c.preDM  i.kantonsrat $X, i(wk18) fe vce(clu wk18)
xtreg $y c.RatioDM_kr18 c.RatioDM_kr18#c.preDM i.kantonsrat $MP $X, i(wk18) fe vce(clu wk18)
xtreg $y c.RatioDM_kr18 c.RatioDM_kr18#c.preDM  i.kantonsrat $X if preDM > 2, i(wk18) fe vce(clu wk18)

use dataKR2, clear
drop if kantonsrat==16
merge m:1 wk18 using  preDM
*Reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Outcome, district controls and MP characteristics
global y  = "attend" 
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR LeftParty FarmersParty"
*Models
reg $y   c.RatioDM_kr18##c.preDM RatioDM i.kantonsrat $X, vce(clu wk18)
xtreg $y c.RatioDM_kr18 c.RatioDM_kr18#c.preDM  i.kantonsrat $X, i(wk18) fe vce(clu wk18)
xtreg $y c.RatioDM_kr18 c.RatioDM_kr18#c.preDM  i.kantonsrat $MP $X, i(wk18) fe vce(clu wk18)
xtreg $y c.RatioDM_kr18 c.RatioDM_kr18#c.preDM  i.kantonsrat $X if preDM > 2, i(wk18) fe vce(clu wk18)


********************
*TABLE S3.10
***********************
*Congruence models
use dataKR1, clear
*Reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Outcome, district controls and MP characteristics
global y  = "congruence"  
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR LeftParty FarmersParty"
*Models for columns 1-3 are on individual-level
xtreg $y RatioDM_kr18 kr18  mLocPol $MP $X  i.vID, i(wk18) fe vce(clu wk18)
xtreg $y RatioDM_kr18 kr18  mSeniority $MP $X  i.vID, i(wk18) fe vce(clu wk18)
xtreg $y RatioDM_kr18 kr18 mLocPol  mSeniority $MP $X  i.vID, i(wk18) fe vce(clu wk18)

*Attendance models
use dataKR2, clear
drop if kantonsrat==16
*Reform intensity
gen RatioDM_kr18 = RatioDM*kr18
*Outcome, district controls and MP characteristics
global y  = "attend" 
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR LeftParty FarmersParty"
*Models
xtreg $y RatioDM_kr18 kr18 mLocPol $MP $X, i(wk18) fe vce(clu wk18)
xtreg $y RatioDM_kr18 kr18 mSeniority $MP $X, i(wk18) fe vce(clu wk18)
xtreg $y RatioDM_kr18 kr18 mLocPol mSeniority $MP $X, i(wk18) fe vce(clu wk18)


*************
*Figure S3.2
**************
use dataKR2, clear
keep if kantonsrat==18
gen mPartyCat= 0
replace mPartyCat=1 if LeftParty==1
replace mPartyCat=2 if FarmersParty==1
lab define mPartyCatl 0 "Bourgeois Parties" 1 "Social Democratic Party" 2 "Farmer's Party"
lab val mPartyCat mPartyCatl
graph box attend, over(mPartyCat) ytitle("Parliamentary attendance of MPs") scheme(s1mono)
graph export fig-att.pdf, replace



********************
*TABLE S3.11
***********************
*Congruence models
use dataKR1, clear
*Outcome, district controls and MP characteristics
global y  = "congruence"  
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR"
*Models
reg $y   LeftParty  $X if kantonsrat==17, vce(clu wk18)
reg $y   LeftParty  $X $MP if kantonsrat==17, vce(clu wk18)
reg $y   LeftParty  $X if kantonsrat==18, vce(clu wk18)
reg $y   LeftParty  $X $MP if kantonsrat==18, vce(clu wk18)


*Attendance models
use dataKR2, clear
*Outcome, district controls and MP characteristics
global y  = "attend" 
global X = "JaAnteilRef JaAnteilRefSq  foreign_pop relig_frac lang_frac  industry_share" 
global MP = "mDeath age mWorker mFarmer mNR"
*Models
reg $y   LeftParty  $X if kantonsrat==17, vce(clu wk18)
reg $y   LeftParty  $X $MP if kantonsrat==17, vce(clu wk18)
reg $y   LeftParty  $X if kantonsrat==18, vce(clu wk18)
reg $y   LeftParty  $X $MP if kantonsrat==18, vce(clu wk18)



